package com.leisurexi.gedis.client.handler;

import com.leisurexi.gedis.client.protocol.ResponseProtocol;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

import static com.leisurexi.gedis.client.GedisClient.responseQueue;

/**
 * @author: leisurexi
 * @date: 2021-07-30 14:03
 */
@ChannelHandler.Sharable
@Slf4j
public class ResponseHandler extends SimpleChannelInboundHandler<ResponseProtocol> {

    public static final ResponseHandler INSTANCE = new ResponseHandler();

    private ResponseHandler() {
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ResponseProtocol responseProtocol) throws Exception {
        responseQueue.offer(responseProtocol);
        log.info(responseProtocol.toString());
    }

}
